package com.wuseguang.springcloud.controller;


import com.wuseguang.springcloud.Filter.RequestParameterWrapper;
import com.wuseguang.springcloud.entity.StudentFaces;
import com.wuseguang.springcloud.entity.StudentFacesTwo;
import com.wuseguang.springcloud.service.StudentFacesTwoService;
import com.wuseguang.springcloud.util.Result;
import com.wuseguang.springcloud.util.ZipUncompress;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 * <p>
 * 学生人脸2.0表 前端控制器
 * </p>
 *
 * @author 
 * @since 2020-08-03
 */
@RestController
@RequestMapping("/studentFacesTwo")
public class StudentFacesTwoController {


    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private StudentFacesTwoService studentFacesTwoServiceImpl;

    /**
     * 查询班级学生的人脸信息
     * @param request
     * @param classid
     * @return
     */
    @RequestMapping("/findClassStudentFacesTwo")
    public Result findClassStudentFacesTwo(RequestParameterWrapper request,
                                           @RequestParam("classId") Integer classid){
        logger.info("查询班级的学生人脸注册信息");
        //获取学校id
        String schoolId = request.getParam("schoolId");
        return studentFacesTwoServiceImpl.findClassStudentFacesTwo(classid,schoolId);
    }

    /**
     * 添加学生人脸信息
     * @param request
     * @param StudentFacesTwo
     * @return
     */
    @RequestMapping("/addSutdentFacesTwo")
    public Result addSutdentFacesTwo(RequestParameterWrapper request,  StudentFacesTwo StudentFacesTwo){
        logger.info("添加学生人脸注册信息");
        //获取学校id
        String schoolId = request.getParam("schoolId");
        StudentFacesTwo.setSchoolId(Integer.valueOf(schoolId));
        return studentFacesTwoServiceImpl.addSutdentFacesTwo(StudentFacesTwo);
    }

    /**
     * 删除学生人脸信息
     * @param request
     * @param studentId 学生id
     * @return
     */
    @RequestMapping("/delateStudentFacesTwo")
    public Result delateStudentFacesTwo(RequestParameterWrapper request,
                                     @RequestParam(value = "studentId" ) String  studentId){
        logger.info("删除学生的人脸信息");
        //获取学校id
        String schoolId = request.getParam("schoolId");
        return studentFacesTwoServiceImpl.delateStudentFacesTwo(studentId,schoolId);
    }

    /**
     * 推送学生人脸信息
     * @param request
     * @return
     */
    @RequestMapping("/stuentFacesRegisterTwo")
    public Result stuentFacesRegister(RequestParameterWrapper request){
        logger.info("推送学生人脸信息");
        //获取学校id
        String schoolId = request.getParam("schoolId");
        return studentFacesTwoServiceImpl.stuentFacesRegisterTwo(schoolId);
    }


    /**
     * 导入学生r人脸
     * @param request
     * @param uploadFile  相片
     * @return
     */
    @RequestMapping("/importStudentFaces")
    public Result importStudentFaces(RequestParameterWrapper request,
                                        @RequestParam("uploadFile") MultipartFile uploadFile) {
        logger.info("导入学生相片");
        //获取学校id
        String schoolId = request.getParam("schoolId");


        return studentFacesTwoServiceImpl.importStudentFaces(uploadFile,schoolId);
    }


    /*无用@RequestMapping("/synchronousFacesTwo")
    public Result synchronousFacesTwo(RequestParameterWrapper request,String gradeId){
        logger.info("同步人脸");

        return studentFacesTwoServiceImpl.synchronousFacesTwo(gradeId);
    }*/


    /**
     * 导入学生r人脸
     * @param request
     * @return
     */
    @RequestMapping("/importStudentFacesTwo")
    public Result importStudentFaces(RequestParameterWrapper request) {
        logger.info("导入学生相片");
        //获取学校id
        String schoolId = request.getParam("schoolId");


        return studentFacesTwoServiceImpl.importStudentFaces(schoolId);
    }

}

